package com.flying.rsocket;

import org.springframework.boot.rsocket.messaging.RSocketStrategiesCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.messaging.rsocket.DefaultMetadataExtractor;
import org.springframework.messaging.rsocket.MetadataExtractor;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;

import java.util.Map;

@Configuration
public class ServerConfiguration {
    @Bean
    public RSocketStrategiesCustomizer strategyCustomizer() {
        return (strategy) -> strategy.metadataExtractorRegistry(registry -> {
            registry.metadataToExtract(MimeTypeUtils.APPLICATION_JSON, String.class, MetadataExtractor.ROUTE_KEY);
        });
    }
}
